import request from "@/utils/request2"
import dayjs  from "dayjs";
// get 方式，传参使用 params
// post 方式，传参使用 data

/**
 * 
 * @param {*} type  0：水库；1：水闸；2：河道点；3：电排站    999全部类型   hasRecord 运行中
 * @returns 
 */
const getLocation = ( type = 999,hasRecord = 'true') => {
  var params = {type:type};
 // if (hasRecord !== undefined) { params['hasRecord'] =hasRecord };
  return request({
    url: '/getLocation',
    method: 'get',
    params: params
  })
}

/**
 * doc https://www.showdoc.com.cn/2373392222702844/10594616180717073
 * 根据指定设备编号返回水位数据
 * @param {*} device    8603
 * @param {*} startTime  2023-08-29
 * @param {*} endTime  2023-09-28
 * @returns 
 */
const getWaterLevelByHour = (device, startTime, endTime) => {
  return request({
    url: '/getWaterLevelByHour',
    method: 'get',
    params: { device, startTime, endTime }
  })
}

/**
 * 获取5分钟雨晴或者水情
 * @param {String} device 
 * @param {String} startTime 
 * @param {String} endTime 
 * @param {Number} type 0雨量，1水位
 * @returns 
 */
const getFiveMinuteData = (device, startTime, endTime, type = 0) => {
   
  return request({
    url: "/fiveMinuteData",
    method: "get", params: { device, startTime, endTime, type }
  })
}
const fetchData = (hasRecord = 'true', type = undefined) => {
  var params = { hasRecord: hasRecord };
  if (type !== undefined) { params['type'] = type };
  return request({
    url: '/fetchData',
    method: 'GET'
  })
}

const HoursRain=(date=new Date())=>{
  const timeStr = dayjs(date).format('YYYYMMDDhhmm');
  return request({
    'url':'https://devapi.qweather.com/v7/minutely/5m?location=113.07859,22.59677&key=95cf38cd40b84df9beae340c610e8550',
    method:'GET'
  })
}

const  videoList = ()=>{
  return request({
    'url':'http://pjyj.qt.xingfeng666.cn:9100/data/list.json'
  });
}

export { getLocation, getWaterLevelByHour, getFiveMinuteData, fetchData,HoursRain,videoList }